package org.javaboy.fmall.utils.returnTool;

/**
 * @ClassName BusinessException 自定义异常状态处理类
 * @Description
 * @Author find me
 * @Date 2020/7/19 0019 15:30
 * @Version 1.0
 */
public class BusinessException extends RuntimeException  {

    public Integer code;
    public String  msg;

    public BusinessException(ColeMessage coleMessage) {
        ColeMessage coleMessage2 = convertEnumToType(coleMessage.toString());
        this.code = coleMessage2.getCode();
        this.msg = coleMessage2.getMessage();

    }

    public BusinessException(String msg,Integer code) {
        this.msg = msg;
        this.code = code;
    }


    public BusinessException(String msg) {
        this.code = 201;
        this.msg =msg;

    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }


    /**
     * 翻译枚举类成具体的数据
     *
     * @param startType
     * @return
     */
    private ColeMessage convertEnumToType(String  startType) {
        ColeMessage coleMessage = ColeMessage.valueOf(startType);
        return coleMessage;
    }

}